;当此脚本已经运行时自动替换旧实例再次运行。
#SingleInstance,force

;alt+s >>>>>>>>>>>>>>>>>>>>>>>>>常用快捷输入内容<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
!s::
	QuickInputList=
	(Ltrim
		&1)%A_MM%%A_DD%%A_Hour%%A_Min%
		&2)%A_YYYY%%A_MM%%A_DD%
		&3)%A_YYYY%-%A_MM%-%A_DD%
		&4)%A_YYYY%.%A_MM%.%A_DD%
		&5)%A_YYYY%年%A_MM%月%A_DD%日
		&e)%A_YYYY%.%A_MM%.%A_DD% %A_Hour%:%A_Min%
		&a)%A_YYYY%.%A_MM%.%A_DD% nijs
		&s)nijsLog%A_Min%
		&d)更新v-pm、pm-pro-s、pm-pro-w、pm-su-s、pm-su-w，提交develop时间：%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%
		&q)
		&t)更新v-pm、pm-pro-s、pm-pro-w、pm-su-s、pm-su-w，提交trunk时间：%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%
		&z)nijsNeedRevert
	)
	MySub_QuickInput(QuickInputList)
return

;sql相关/**/
::sel::select from
::cnt::count()
::wh1::where 1 = 1
::where1::where 1 = 1
::gb::group by
::od::order by

;alt+t >>>>>>>>>>>>>>>>>>>>>>>>>任意窗口透明化<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
!t::
MouseGetPos,,, MouseWin
WinGet, Transparent, Transparent, ahk_id %MouseWin%
;ToolTip Translucency:`t"%Transparent%"`nTransColor:`t%TransColor%
if Transparent!=
WinSet, TransColor, Off, ahk_id %MouseWin%
;关闭透明
else
{
MouseGetPos, MouseX, MouseY, MouseWin
PixelGetColor, MouseRGB, %MouseX%, %MouseY%, RGB
; 似乎有必要首先关闭任何现有的透明度:
WinSet, TransColor, Off, ahk_id %MouseWin%
; 透明度255(完全不透明).
WinSet, TransColor, %MouseRGB% 50, ahk_id %MouseWin%
}
return

;win+/ 注释开关 待实现  #/::


;F10 >>>>>>>>>>>>>>>>>>>>>>>>>窗口置顶<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;https://blog.csdn.net/weixin_35944332/article/details/128755667
F10:: ;最爱代码之窗口置顶
    WinGet ow, id, A
    WinTopToggle(ow)
    return

WinTopToggle(w) {
    WinGetTitle, oTitle, ahk_id %w%
    WinGet, transparent, Transparent, ahk_id %w%
    Winset, AlwaysOnTop, Toggle, ahk_id %w%
    WinGet, ExStyle, ExStyle, ahk_id %w%
    if (ExStyle & 0x8)  ; 0x8 为 WS_EX_TOPMOST.在WinGet的帮助中
        {	Topps = 置顶
			transparent := 230
			WinSet, Transparent, %transparent%, ahk_id %w%
			
		}
    else{
			Topps = 取消置顶
			transparent := 250
			WinSet, Transparent, %transparent%, ahk_id %w%
        }
    tooltip %oTitle% %Topps%
    SetTimer, RemoveToolTip, 3000
    return

    RemoveToolTip:
    SetTimer, RemoveToolTip, Off
    ToolTip
    return
}


;F4 >>>>>>>>>>>>>>>>>>>>>>>>>使用示例，将下划线、驼峰互转<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
F4::
    SelectedText := ChangeSelectTextHump()
	CopyText(SelectedText)
    ; MsgBox, 64, 提示, 所选文本是:`n%SelectedText%
Return

;Shift+x >>>>>>>>>>>>>>>>>>>>>>>>>将大小写互转<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
+x::
    SelectedText := ChangeSelectTextUL()
	CopyText(SelectedText)
    ; MsgBox, 64, 提示, 所选文本是:`n%SelectedText%
Return

; 定义一个函数来获取所选文本
GetSelectedText()
{
    ; 定义变量来保存返回的文本
    Static SelectedText := ""
	; 复制选中的文本到剪贴板
    Send, ^c
    Sleep, 100
    ; 读取剪贴板的内容
	SelectedText = %Clipboard%
    return SelectedText
}

; 大小写转换
ChangeSelectTextUL()
{
    ; 获取选中的内容
	SelectedText := GetSelectedText()
	if(RegExMatch(SelectedText, "([A-Z])")){
		; MsgBox, 64, 提示, 大写，转为小写！
		SelectedText := RegExReplace(SelectedText,"([A-Z]*)","$L1")
	}else if(RegExMatch(SelectedText, "([a-z])")){
		; MsgBox, 64, 提示, 大写，转为小写！
		SelectedText := RegExReplace(SelectedText,"([a-z]*)","$U1")
	}else{
		; MsgBox, 64, 提示, 暂未匹配！
	}
    return SelectedText
}

; 下划线驼峰转换
ChangeSelectTextHump()
{
	; 获取选中的内容
	SelectedText := GetSelectedText()
	if(RegExMatch(SelectedText, "([a-z])-([a-z])")){
		; MsgBox, 64, 提示, 中划线转下划线！
		SelectedText := RegExReplace(SelectedText,"([a-z])-([a-z])","$1_$2")
	}else if(RegExMatch(SelectedText, "([a-z])_([a-z])")){
		; MsgBox, 64, 提示, 下划线转驼峰！
		SelectedText := RegExReplace(SelectedText,"([a-z])_([a-z])","$1$U2")
	}else if(RegExMatch(SelectedText, "([a-z])([A-Z])")){
		; MsgBox, 64, 提示, 驼峰，转为下划线！
		SelectedText := RegExReplace(SelectedText,"([a-z])([A-Z])","$1_$L2")
	}else{
		; MsgBox, 64, 提示, 暂未匹配！
	}
    return SelectedText
}

; 将内容放入剪贴板，并粘贴
CopyText(copyText)
{
	; 将新内容放入剪贴板
	Clipboard := copyText  
	; 发送Ctrl+V粘贴剪贴板内容
    Send, ^v
}



;参考地址：https://www.autoahk.com/archives/9216

;我的过程或函数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MySub_QuickInput(String){
		menu,KyMenu_QuickInput,Add
		menu,KyMenu_QuickInput,DeleteAll
		Loop,parse,String,`n,`r
		{
			if (A_LoopField="")
				continue
			if (A_LoopField="-")
				menu,KyMenu_QuickInput,Add
			else
				menu,KyMenu_QuickInput,Add,% A_LoopField,KyMenu_QuickInput_Handler
		}
		menu,KyMenu_QuickInput,show
	return
 
	KyMenu_QuickInput_Handler:
		PostMessage, 0x50, 0, 67699721, , A
		outputStr:=substr(A_ThisMenuItem,4,strlen(A_ThisMenuItem))
		SendInput   {raw}%outputStr%
	return
}
